<template>
	<view class="tabs">
		<view class="tabs_item" v-for="(item,index) in list" :key="index" @click="changeActive(index)">
			<view class="tabs_item_title" :class="{'active': index == activeIndex}">
				{{ item.name }}
			</view>
			<view class="tabs_item_border" v-if="index == activeIndex">
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			list: {
				type: Array,
				default: () => {
					return []
				}
			},
			activeIndex: {
				type: [String,Number],
				default: 0
			}
		},
		data() {
			return {
			}
		},
		methods:{
			changeActive(status) {
				// console.log(status,'status');
				this.$emit('active',status)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		width: 100%;
		padding: 22rpx 38rpx 0 42rpx;
		background: #fff;
		display: flex;
		justify-content: space-between;
		overflow-x: auto;
		.tabs_item {
			position: relative;
			padding-bottom: 20rpx;
			white-space: nowrap;
			
			&:nth-child(n+2) {
				margin-left: 36rpx;
			}
			.tabs_item_title {
				height: 32rpx;
				line-height: 32rpx;
				font-size: 26rpx;
				font-family: Roboto, Roboto-Regular;
				font-weight: 400;
				color: #b9b9b9;
			}
			.tabs_item_border {
				width: 30rpx;
				height: 6rpx;
				margin-top: 20rpx;
				background: #ee5016;
				position: absolute;
				left: 50%;
				bottom: 0;
				transform: translateX(-50%);
			}
		}
		.active {
			color: #ee5016 !important;
		}
	}
</style>
